from pydantic import BaseModel
from typing import List, Optional, Dict
from datetime import datetime

class ServiceStatus(BaseModel):
    """服务状态模型"""
    running: bool
    timestamp: datetime = None

class EmailStats(BaseModel):
    """邮件统计模型"""
    total_processed: int
    today_processed: int
    success_rate: float
    total_approved: int

class ProcessedEmail(BaseModel):
    """已处理邮件模型"""
    message_id: str
    processed_time: datetime
    # 新增字段
    sender: Optional[str] = None
    subject: Optional[str] = None
    email_date: Optional[datetime] = None

class StartServiceResponse(BaseModel):
    """启动服务响应模型"""
    message: str

class StopServiceResponse(BaseModel):
    """停止服务响应模型"""
    message: str

class ServiceStatusResponse(BaseModel):
    """服务状态响应模型"""
    running: bool

class StatsResponse(EmailStats):
    """统计响应模型"""
    pass

class ProcessedEmailsResponse(BaseModel):
    """已处理邮件响应模型"""
    emails: List[ProcessedEmail]

# 数据模型层初始化文件